import { constantRoutes } from '@/router'
import { asyncRoutes } from '@/router'
export default {
  namespaced: true,
  state: {
    Routes: constantRoutes // 所有人拥有的静态路由
  },
  mutations: {
    setRoutes(state, newRoutes) {
      // newRoutes是用户的动态路由
      state.Routes = [...constantRoutes, ...newRoutes]
    }
  },

  actions: {
    filterRoutes(context, menes) {
      const res = asyncRoutes.filter(item => {
        return menes.includes(item.name)
      })

      context.commit('setRoutes', res)
      return res
    }
  }
}
